﻿import mx.events.EventDispatcher;
import mx.utils.Delegate;

import com.dmotiko.general.*

class BaseClip 
extends MovieClip {
	
   public var addEventListener:Function;
   public var removeEventListener:Function;
   public var dispatchEvent:Function; 
   
   private var data:Object;
	
	private function BaseClip(){
		EventDispatcher.initialize(this);
		initClip();
		if(this._parent.childLoaded){
			addEventListener(BaseClipEvent.LOADED, Delegate.create(this._parent, this._parent.childLoaded));
			dispatchEvent( { type: BaseClipEvent.LOADED, target: this});
		}
	}
	
	/**
	 * @author: sminutoli
	 * @usage:  deja que se inicialicen primero las variables y luego tira el evento de onLoad. Su uso es para la herencia
	 */
	private function initClip(){
		return;
	}
	
	public function getData():Object {
		return this.data;
	}
	
	public function setData(data:Object):Void {
		this.data = data;
		refreshData();
	}
	/**
	 * @author: sminutoli
	 * @usage:  Su uso es para la herencia
	 */
	private function refreshData():Void {
		return;
	}
	
	private function getChild(name:String) {
		return this[name];
	}
	
}